//
//  SearchResultsViewController.m
//  TheRoadAD
//
//  Created by 宁宁 on 16/8/26.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "SearchResultsViewController.h"

#import "TunerTableViewCell.h"//cell

#import "TrackDayDetailViewController.h"//活动详情Controller
#import "OthersHomePageViewController.h"//他人主页Controller

@interface SearchResultsViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation SearchResultsViewController

 static NSString *const TunerTableViewCellID = @"TunerTableViewCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNav];
    
    //注册TableView
    [self registerTableView];
}
//设置导航栏
- (void)setNav{
    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_home_meitu_1"] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    self.navigationItem.leftBarButtonItem = back;
}

//注册TableView
- (void)registerTableView{
    [self.tableView registerNib:[UINib nibWithNibName:@"TunerTableViewCell" bundle:nil] forCellReuseIdentifier:@"TunerTableViewCell"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    //    return _modelsArray.count;
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TunerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TunerTableViewCell"];
    cell.name.text = @"用户名";
    cell.time.text = @"2016-05-20 16:55";
    cell.picNum.text = @"9图";
    cell.content.text = @"21号下午黄龙约起!";
    
    //    if (@"自己") {
    //        [cell.firstBtn setTitle:@"筛选" forState:UIControlStateNormal];
    //        [cell.firstBtn setImage:[UIImage imageNamed:@"icon_baoming"] forState:UIControlStateNormal];
    //    }else{
    [cell.firstBtn setTitle:@"报名" forState:UIControlStateNormal];
    [cell.firstBtn setImage:[UIImage imageNamed:@"icon_baoming"] forState:UIControlStateNormal];
    //    }
    
    cell.cellClick = ^(int temp){
        switch (temp) {
            case 0:
            {
                //                if (@"自己") {
                //                    NSLog(@"筛选");
                //                }else {
                NSLog(@"报名");
                //                }
            }
                break;
            case 1:
            {
                NSLog(@"评论");
            }
                break;
            case 2:
            {
                NSLog(@"分享");
            }
                break;
            case 3:
            {
                OthersHomePageViewController *others = [[OthersHomePageViewController alloc] init];
                others.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:others animated:YES];
            }
            default:
                break;
        }
    };
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //有内容140 没内容100
    return 140 + Screen_Width / 25 * 12;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    TrackDayDetailViewController *detail = [[TrackDayDetailViewController alloc] init];
    detail.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:detail animated:YES];
}


- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}


- (UITableView *)tableView{
    if (!_tableView) {
        _tableView= [[UITableView alloc]initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height)style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.showsVerticalScrollIndicator = NO;//去掉滑动竖条
        [self.view addSubview:_tableView];
    }
    return _tableView;
}

@end
